{% extends "../basepage.html" %}
{% block js %}

<script type="text/javascript" language="javascript">
<!--
function doCheking(obj,number){
	var table = document.getElementById("contentList");
	var trObj = getRowObj(obj); 
	var trNo = getRowNo(obj);
	var trArr = getAllRowNo(obj);
	var currentValue = table.rows[trNo-1].cells[1].innerHTML;
	if (number==1){
		if((trNo-1)==1){
			var textValue='';
		}else{
			var textValue = table.rows[trNo-2].cells[1].innerHTML;
		}
	}
	if (number==2){
		if ((trNo-1)==0){
			textValue = '';
			if(trArr==trNo){
				var currentValue = '';
			}else{
				var currentValue = table.rows[trNo].cells[1].innerHTML;
			}
		}
		else{
			var textValue = currentValue;
			if (trArr==trNo){
				currentValue = '';
			}else{
				currentValue=table.rows[trNo].cells[1].innerHTML;
			}
		}
	}
	//alert(textValue);
	//alert(currentValue);
	document.getElementById("hidden1").value = textValue;
	document.getElementById("hidden2").value = currentValue;
}

function getRowNo(obj){
   	var trObj = getRowObj(obj); 
   	var trArr = trObj.parentNode.children;
 	for(var trNo= 0; trNo < trArr.length; trNo++){
  		if(trObj == trObj.parentNode.children[trNo]){
    		return (trNo+1);
  		}
 	}
}

function getAllRowNo(obj){
	var trObj = getRowObj(obj); 
   	var trArr = trObj.parentNode.children;
	return trArr.length;
}

function getRowObj(obj)
{
   var i = 0;
   while(obj.tagName.toLowerCase() != "tr"){
    obj = obj.parentNode;
    if(obj.tagName.toLowerCase() == "table")
  		return null;
   }
   return obj;
}

function getDateTimeStamp(dateStr){
 	return Date.parse(dateStr.replace(/-/gi,"/"));
}

function aaa()
{
	var table = document.getElementById("contentList");
	var trNo = table.rows.length;
	for (i=1;i<table.rows.length;i++){
		var str = table.rows[i].cells[3].innerHTML;
		var cd=str.length;
		if(cd>12){
			table.rows[i].cells[3].innerHTML=str.substring(0,12)+"...";
		}
	}
}
-->
</script>
<!--xieyingan加的代码-->
<script language="javascript">
///通过单击行反选该行所有CheckBox
function SelectTR(tr)
{
  var tds=tr.childNodes;
  for(var j=0; j<tds.length;j++)
  {
	var inputs=tds[j].childNodes;
	for (var i=0; i < inputs.length; i++) // 遍历页面上所有的 input
    {
	  if (inputs[i].type == "radio")
		{
		  inputs[i].checked = !inputs[i].checked;
		  //tr.style.backgroundColor = inputs[i].checked ? "#245EDC" : ""; //改变选中行的背景色
	  }
	}
  }
}
</script>
<script for = btnNext event=onclick>////下一层
   var value="";
   for (var i=0;i<box.length;i++ ){
     if(box[i].checked){ //判断复选框是否选中
    	value=value+box[i].value; //值的拼凑 .. 具体处理看你的需要,
	 }
   }
   if(value==null||value==""){
   	alert("请选择一条数据进行操作");
   }else{
   window.location.href="/contentList/0?father=" + value;
   }
</script>
<script for = btnCon event=onclick>////特殊资讯
   window.location.href="/replyContentAdd?father={{father}}&prev=&next=&prevValue=&page_id=0";
</script>
<script for = btnExit event=onclick>////编辑
   var value="";
   var index="";
   var father="";
   if(!box.length){
   	if(box.checked){
   		value=box.value; //值的拼凑 .. 具体处理看你的需要
		index=rindex.value;
		father=rfather.value;
   }}
   for (var i=0;i<box.length;i++ ){
     if(box[i].checked){ //判断复选框是否选中
    	value=value+box[i].value ; //值的拼凑 .. 具体处理看你的需要
		index=index+rindex[i].value;
		father=father+rfather[i].value;
	 }
   }
   if(value==null||value==""){
   	alert("请选择一条数据进行操作");
   }else{
   window.location.href="/contentUpdate?contentCode=" + value + "&page_id="+index+"&father="+father;
   }
</script>
<script for = btnDel event=onclick>////删除
   var value="";
   var index="";
   var f="";
   if(!box.length){
   	if(box.checked){
   		value=box.value; //值的拼凑 .. 具体处理看你的需要
		index=rindex.value;
		father=rfather.value;
   }}
   for (var i=0;i<box.length;i++ ){
     if(box[i].checked){ //判断复选框是否选中
    	value=value+box[i].value; //值的拼凑 .. 具体处理看你的需要
		index=index+rindex[i].value;
		father=f+rfather[i].value;
	 }
   }
   if(value==null||value==""){
   	alert("请选择一条数据进行操作");
   }else{
	   if(window.confirm("你确认要删除吗？"))
	   window.location.href="/contentDelete?contentCode=" + value + "&page_id="+index+"&father="+father;
   }
</script>
<script language="javascript"><!-- 改变单元格背景色 -->
 function cells_color(){
	var oColor,td=event.srcElement
	 if(td.tagName!="TD")
	   return ;
	if(event.type=="mouseover"){
		oColor="#C5D7EF";
		}
		
	 else{ 
	 	oColor="#ffffff"
	 }
	 tr=td.parentElement
	 for(var i=0;i<tr.cells.length;i++)
		 tr.cells[i].bgColor=oColor
 }

</script>
<!--xieyingan加的代码END-->
{% endblock %}
{% block body %}
<body onLoad="aaa();"  style="background:#ececec">
{% endblock %}
{% block navigator %}
<a  href="/contentList/0">资讯内容管理</a> 
{% for fList in fatherList%}
{% if fList.code%}
 >> <a href="/contentList/0?father={{fList.code}}">{{fList.title}}</a>
{%endif%}
{% endfor%}
 >> <a href="javascript:history.back(-1);">后退</a>
{% endblock %}
{% block content %}

<form  method="post" action="/contentList/{{index}}">
<table id="contentList"    border="0" cellpadding=1 cellspacing=1 bgcolor="#D5E3E6" >
<tr bgcolor="#ffffff" height="25">
	<td colspan="10" align="right">
		<input type="hidden" id="hidden" name="hidden" value="{{father}}">
<input type="hidden" id="prevValue" name="prevValue" value="{{prevValue}}">
<input type="hidden"  name="prevcode" value="{% if prev%}{{prev}}{%endif%}">
<input type="hidden"  name="nextcode" value="{% if next%}{{next}}{%endif%}">
  {% ifequal contentlength 0 %}
  {% ifnotequal father 0 %}
  <input type="button" name="btnCon" value="添加特殊资讯"/>
  {% endifnotequal%}
  {% endifequal%}
  <input type="submit" name="do" value="插入"  />
  <input type="submit" name="do" value="添加"  />
  <input type="button" name="btnExit" value="编 辑"/>
  <input type="button" name="btnDel" value="删 除" />
	</td>
</tr>
<tr bgcolor="#ffffff"  height="25">
<td width="40px"  align="center">主编码</td>
		<td width="60px" align="center">内容编码</td>
		<td width="200px" align="center">抬头标题</td>
		<td width="200px" align="center">内容</td>
		<td width="40px" align="center">父类</td>
		<td width="60px" align="center">资讯等级</td>
		<td width="60px" align="center">资讯状态</td>
		<td width="120px;" align="center">最后更新时间</td>
		<td width="90px;" align="center">更新时间间隔</td>
<td width="20px;">&nbsp;</td>
</tr>
{% for content in contents%}
{% if content.code %}
<tr style="cursor:hand"  height="25" onClick="SelectTR(this);"  onmouseover="cells_color();" onMouseOut="cells_color();" bgcolor="#ffffff">
<td align="center">{{content.maincode}}</td>
<td align="center"><a href="/replyContentList/0?father={{content.code}}">{{content.code}}</a></td>
<td>{{content.title}}</td>
<td>{{content.content}}</td>
<td align="center">{{content.father}}</td>
<td align="center">{{content.level}}</td>
<td align="center">{{content.status}}</td>
<td align="center">{{ content.lastUpdateTime|date:"Y-m-d H:i:s"}}</td>
<td align="center">{{content.updateSpanTime}}</td>

<td ><input name="cbox" type="radio" id="box" value="{{content.code}}" >
  <input name="prev" style="visibility:hidden; display:none" type="radio"  value="{{content.prev}}" >
  <input name="code" style="visibility:hidden; display:none" type="radio"  value="{{content.code}}" >
  <input name="next" style="visibility:hidden; display:none" type="radio"  value="{{content.next}}" >
  <input name="radio" style="visibility:hidden; display:none" type="radio" id="rindex" value="{{index}}" >
  <input name="radio" style="visibility:hidden; display:none" type="radio" id="rfather" value="{{father}}" >
</td>
</tr>
{%endif%}
{%endfor%}
<tr bgcolor="#ffffff"  height="25">
	<td colspan="10" align="right" >
		{% if prevpage %}<a href="/contentList{{prevpage}}?father={{father}}">上一页</a>{% endif%}  {%if nextpage%}<a id="link2" href="/contentList{{nextpage}}?father={{father}}">下一页</a>{% endif %} {%if lastpage%}<a id="link2" href="/contentList/{{lastpage}}?father={{father}}">最后一页</a>{% endif %}
	</td>
</tr>
</table>
 <script type="text/javascript" language="javascript">
    for (i=0;i<contentList.rows.length;i++) 
    {
        if(i%2==0)
        {
            contentList.rows(i).className = "a1";
        }
        else
        {
            contentList.rows(i).className = "";
        }
　　}
</script>
</form>
{% endblock %}